package com.kevin.training.meal.controller;

import java.util.Date;
import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.kevin.training.meal.service.UserService;

@Controller
public class HomeController {

	@Inject
	private UserService accountService;

	@RequestMapping({"/", "/home"})
	public String showHomePage(Map<String, Object> model) {
		Date date = new Date();
		model.put("message", date.toString());
		return "home";
	}

	@RequestMapping(value={"/login"}, method=RequestMethod.GET)
	public String login(@RequestParam("username") String username, Model model) {
		model.addAttribute("username", username);
		return "hello";
	}

	public void setAccountService(UserService accountService) {
		this.accountService = accountService;
	}
}
